package com.chenziwen.scala.chapter04

object Scala07_Exception {
  def main(args: Array[String]): Unit = {
    try {
      val num = 10 / 0
    } catch {
      // 先捕获，先返回
      case e: ArithmeticException => println("捕获了除数为零的算数异常" + e.printStackTrace())
      case e: Exception => println("捕异常" + e.printStackTrace())
    } finally {
      println("finally code ...")
    }

    //得到方法区的内存 就是java中的NumberFormatException.class
    @throws(classOf[NumberFormatException])
    def f1() = {
      "abc".toInt
    }

    f1()
  }
}
